home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 34.zip
/
BS1 part 34
/
FredFish PD 314.adf
/
Zc
/
zcsrc.lzh
/
IOLib
/
stdio
/
fputc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-05-20
|
655b
|
31 lines
#include <stdio.h>
int fputc(c, fp)
register unsigned char c;
register FILE *fp;
{
register int f, m, mustflush, rv;
f = (fp->_flag |= _IORW);
if(!(f & _IOWRT) /* not opened for write? */
|| (f & (_IOERR | _IOEOF))) /* error/eof conditions? */
return(EOF);
if(fp->_base == NULL) /* allocate a buffer if there wasn't one */
_getbuf(fp);
_fputc:
*(fp->_ptr)++ = c;
mustflush = (fp->_flag & _IODEV) && (c == '\n');
if((++(fp->_cnt)) >= fp->_bsiz || mustflush)
{
fp->_ptr = fp->_base;
m = fp->_cnt;
if((rv = write(fp->_file, fp->_base, m)) != m)
{
fp->_flag |= _IOERR;
return(EOF);
}
fp->_cnt = 0;
}
return(c);
}